package com.ymatou.app.seller.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

public class GetActivityListBySellerCall extends YmatouBaseCall {
	private static String opurl = "api/Activity/GetActivityListBySeller";

	public GetActivityListBySellerCall() {
		super(EnvSetup.getSystemUrl("seller_app"), opurl, "GET", "PARAM");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		//User-Agent: 02ios====8.4.1=DF50A6A6-0281-44BF-9D60-07412CE57EB1============================2.3.1=appStore========
		client.addHeader("User-Agent", "02ios====8.4.1=DF50A6A6-0281-44BF-9D60-07412CE57EB1============================2.3.1=appStore========");
	}

	/**
	 * 获取Data
	 * 
	 * @return Data
	 */
	public JSONObject getResult() {
		JSONObject Data = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			Data = jo.getJSONObject("Result");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}
	/**
	 * 获取最后一个直播的状态 0 直播进行中 1 直播结束
	 * @return
	 */
	public int getLastActivityStatus() {
		int activityState = -1;
		try {
			activityState=getResult().getJSONArray("ActivityList").getJSONObject(0).getInt("ActivityState");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return activityState;
	}
	/**
	 * 获取最后一个直播的ActivityId
	 * @return
	 */
	public int getLastActivityId() {
		int ActivityId = -1;
		try {
			ActivityId=getResult().getJSONArray("ActivityList").getJSONObject(0).getInt("ActivityId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ActivityId;
	}

}
